package com.wcar.frontsso.controller;

import com.alibaba.fastjson.JSON;
import com.wcar.common.entity.FrontUser;

import com.wcar.common.util.WebUtil;
import com.wcar.common.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @BelongsProject: four-wcar-idea
 * @BelongsPackage: com.wcar.frontsso.controller
 * @Author: 李睢康
 * @CreateTime: 2024-05-31  15:16
 */
@RestController
@RequestMapping("/car")
public class FrontUserController {
    @Autowired
    private StringRedisTemplate redisTemplate;
    @GetMapping("/api/getUserInfo")
    public Result<FrontUser> info(){
        String token = WebUtil.getToken();
        ValueOperations<String, String> forValue = redisTemplate.opsForValue();
        String s = forValue.get("font:login:" + token);
        FrontUser frontUser = JSON.parseObject(s, FrontUser.class);
        return new Result<>(200,"获取用户信息成功",frontUser);
    }
}
